# pylint: disable-msg=E1101
"""
@author: Sergiy Tsymbalyuk
"""

import logging

from pylons import tmpl_context as c
from pylons.i18n import lazy_ugettext as _

from chowa.model import District
from chowa.lib.site.navigation import Tab

from pubservices.lib.base import render, Session
from pubservices.lib.base import PublicServicesController 

log = logging.getLogger(__name__)

class UtilitiesController(PublicServicesController):
    __primary_tabs__ = [
        [
            Tab(params=dict(action='index'),
                ignore_params=['analytics',],
                caption=_('Districts'),
                description=_('Districts')
            ),
            Tab(params=dict(action='analysis', service='water', default__analytics='period'),
                caption=_('Water'),
                description=_('Water')
            ),
            Tab(params=dict(action='analysis', service='electricity', default__analytics='period'),
                caption=_('Electricity'),
                description=_('Electricity')
            ),
            Tab(params=dict(action='analysis', service='heating', default__analytics='period'),
                caption=_('Heating'),
                description=_('Heating')
            ),
            Tab(params=dict(action='analysis', service='gas',  default__analytics='period'),
                caption=_('Gas'),
                description=_('Gas')
            ),
        ],
        [
            Tab(params=dict(default__action='total', service='water'),
                caption=_('Water'),
                description=_('Water')
            ),
            Tab(params=dict(default__action='total', service='electricity'),
                caption=_('Electricity'),
                description=_('Electricity')
            ),
            Tab(params=dict(default__action='total', service='heating'),
                caption=_('Heating'),
                description=_('Heating')
            ),
            Tab(params=dict(default__action='total', service='gas'),
                caption=_('Gas'),
                description=_('Gas')
            ),
        ]
    ]
    
    def __init__(self):
        c.main_heading = _('Utilities')
    
    def index(self):
        c.districts = Session.query(District).all()
        return render('/utilities/index.html')
